﻿using System;
using System.Collections.Generic;
using System.Linq;
using Autodesk.Revit.DB;
using YArchitech.Revit.RevitExtension;

namespace YArchitech.Revit
{
	public class YJKLine
	{
		public YJKLine(XYZ start, XYZ end)
		{
			if (!start.IsAlmostEqualTo(end))
			{
				this.line = YJKLineEx.YJKGetBound(start, end);
			}
			this.startPoint = start;
			this.endPoint = end;
		}

		public YJKLine(Line line)
		{
			this.line = line;
			if (line.IsBound)
			{
				this.startPoint = line.GetEndPoint(0);
				this.endPoint = line.GetEndPoint(1);
				return;
			}
			this.isBound = false;
		}

		public XYZ StartPoint
		{
			get
			{
				return this.startPoint;
			}
		}

		public XYZ EndPoint
		{
			get
			{
				return this.endPoint;
			}
		}

		public void MakeUnBound()
		{
			this.isBound = false;
			this.line.MakeUnbound();
		}

		public bool IsBound
		{
			get
			{
				this.isBound = this.line.IsBound;
				return this.isBound;
			}
		}

		public Line Line
		{
			get
			{
				return this.line;
			}
		}

		public XYZ LineVector
		{
			get
			{
				return this.StartPoint.Subtract(this.EndPoint).Normalize();
			}
		}

		public bool IsParallel(Line otherLine)
		{
			bool result = false;
			YJKLine hyline = new YJKLine(otherLine.GetEndPoint(0), otherLine.GetEndPoint(1));
			XYZ xyz = this.startPoint - this.endPoint;
			XYZ xyz2 = hyline.StartPoint - hyline.EndPoint;
			double num = xyz.AngleTo(xyz2);
			if (Math.Abs(num - Math.PI) < 0.0001 || num < 0.0001)
			{
				result = true;
			}
			return result;
		}

		public static int judgeTwoLineRelativePosition(Line Rline, Line line, double rd, double d)
		{
			int result = 0;
			XYZ hyendPoint = Rline.GetEndPoint(0);
			XYZ hyendPoint2 = Rline.GetEndPoint(1);
			XYZ hyendPoint3 = line.GetEndPoint(0);
			XYZ hyendPoint4 = line.GetEndPoint(1);
			YJKLine hyline = new YJKLine(line);
			YJKLine hyline2 = new YJKLine(Rline);
			XYZ xyz = hyline.IntersectionPoint(Rline, 0.001);
			if (xyz != null)
			{
				result = 1;
			}
			else if (xyz == null)
			{
				XYZ dlineP = YJKRevitTools.GetDLineP(hyendPoint, hyendPoint2, hyendPoint3, hyendPoint4);
				XYZ dlineP2 = YJKRevitTools.GetDLineP(hyendPoint3, hyendPoint4, hyendPoint, hyendPoint2);
				bool flag = hyline2.IsPointOnLine(dlineP2);
				bool flag2 = hyline.IsPointOnLine(dlineP);
				double num = Math.Abs(dlineP.DistanceTo(hyendPoint3));
				double num2 = Math.Abs(dlineP.DistanceTo(hyendPoint4));
				bool flag3 = ((num - num2 > 0.0) ? num2 : num) - 1.2 * d >= 1E-08;
				double num3 = Math.Abs(dlineP2.DistanceTo(hyendPoint));
				double num4 = Math.Abs(dlineP2.DistanceTo(hyendPoint2));
				bool flag4 = ((num3 - num4 > 0.0) ? num4 : num3) - 1.2 * rd >= 1E-08;
				if (flag && !flag2)
				{
					if (flag4)
					{
						result = 2;
					}
					else
					{
						result = 3;
					}
				}
				else if (!flag && flag2)
				{
					if (flag3)
					{
						result = 4;
					}
					else
					{
						result = 3;
					}
				}
				else if (flag && flag2)
				{
					if (flag4 && flag3)
					{
						result = 5;
					}
					else if (!flag4 && flag3)
					{
						result = 4;
					}
					else if (flag4 && !flag3)
					{
						result = 2;
					}
					else if (!flag4 && !flag3)
					{
						result = 3;
					}
				}
				else if (!flag && !flag2)
				{
					result = 3;
				}
			}
			return result;
		}

		public static int judgeTwoLineTheirAreInTerst(Line Rline, double rdiamter, Line line, double diameter)
		{
			int result = 0;
			XYZ hyendPoint = Rline.GetEndPoint(0);
			XYZ hyendPoint2 = Rline.GetEndPoint(1);
			XYZ hyendPoint3 = line.GetEndPoint(0);
			XYZ hyendPoint4 = line.GetEndPoint(1);
			YJKLine hyline = new YJKLine(line);
			YJKLine hyline2 = new YJKLine(Rline);
			XYZ xyz = hyline.IntersectionPoint(Rline, 0.001);
			hyendPoint.DistanceTo(hyendPoint2);
			hyendPoint3.DistanceTo(hyendPoint4);
			double num = rdiamter - diameter;
			if (xyz != null)
			{
				double num2 = Math.Abs(xyz.DistanceTo(hyendPoint3));
				double num3 = Math.Abs(xyz.DistanceTo(hyendPoint4));
				bool flag = ((num2 - num3 > 0.0) ? num3 : num2) - 2.0 * diameter >= 1E-08;
				double num4 = Math.Abs(xyz.DistanceTo(hyendPoint));
				double num5 = Math.Abs(xyz.DistanceTo(hyendPoint2));
				bool flag2 = ((num4 - num5 > 0.0) ? num5 : num4) - 2.0 * rdiamter >= 1E-08;
				if (hyline.IsPointOnLine(xyz) && !hyline2.IsPointOnLine(xyz))
				{
					if (flag)
					{
						result = 2;
					}
					else
					{
						result = 3;
					}
				}
				else if (hyline2.IsPointOnLine(xyz) && hyline.IsPointOnLine(xyz))
				{
					if (flag)
					{
						result = 2;
					}
					else if (flag2)
					{
						result = 4;
					}
					else
					{
						result = 6;
					}
				}
				else if (hyline2.IsPointOnLine(xyz) && !hyline.IsPointOnLine(xyz))
				{
					if (flag2)
					{
						result = 4;
					}
					else
					{
						result = 5;
					}
				}
				else if (!hyline2.IsPointOnLine(xyz) && !hyline.IsPointOnLine(xyz))
				{
					result = 6;
				}
			}
			return result;
		}

		public static XYZ get45NewXYZ(Line line1, Line line2, double distance, XYZ nowxyz)
		{
			List<XYZ> source = new List<XYZ>();
			Line line3 = YJKLineEx.YJKGetBound(new XYZ(line1.GetEndPoint(0).X, line1.GetEndPoint(0).Y, 0.0), new XYZ(line1.GetEndPoint(1).X, line1.GetEndPoint(1).Y, 0.0));
			Line otherLine = YJKLineEx.YJKGetBound(new XYZ(line2.GetEndPoint(0).X, line2.GetEndPoint(0).Y, 0.0), new XYZ(line2.GetEndPoint(1).X, line2.GetEndPoint(1).Y, 0.0));
			XYZ point = new YJKLine(line3).IntersectionPoint(otherLine, false);
			new YJKLine(line1);
			YJKLine hyline = new YJKLine(line1.GetEndPoint(0), line1.GetEndPoint(1));
			hyline.MakeUnBound();
			XYZ project = hyline.GetProject(point);
			XYZ hyendPoint = line1.GetEndPoint(0);
			XYZ hyendPoint2 = line1.GetEndPoint(1);
			source = new YJKLine((hyendPoint.DistanceTo(project) > hyendPoint2.DistanceTo(project)) ? hyendPoint : hyendPoint2, project).GetLineXYZList(project, distance);
			if (source.ElementAt(0).DistanceTo(nowxyz) >= source.ElementAt(1).DistanceTo(nowxyz))
			{
				return source.ElementAt(1);
			}
			return source.ElementAt(0);
		}

		public static XYZ getNewLine(Line line1, Line line2)
		{
			new List<XYZ>();
			Line line3 = YJKLineEx.YJKGetBound(new XYZ(line1.GetEndPoint(0).X, line1.GetEndPoint(0).Y, 0.0), new XYZ(line1.GetEndPoint(1).X, line1.GetEndPoint(1).Y, 0.0));
			Line otherLine = YJKLineEx.YJKGetBound(new XYZ(line2.GetEndPoint(0).X, line2.GetEndPoint(0).Y, 0.0), new XYZ(line2.GetEndPoint(1).X, line2.GetEndPoint(1).Y, 0.0));
			YJKLine hyline = new YJKLine(line3);
			XYZ point;
			if (!line1.Direction.IsAlmostEqualTo(line2.Direction))
			{
				point = hyline.IntersectionPoint(otherLine, false);
			}
			else
			{
				point = line1.GetEndPoint(1);
			}
			new YJKLine(line1);
			YJKLine hyline2 = new YJKLine(line1.GetEndPoint(0), line1.GetEndPoint(1));
			hyline2.MakeUnBound();
			XYZ project = hyline2.GetProject(point);
			line2 = YJKLineEx.YJKGetBound(project, line2.GetEndPoint(1));
			return project;
		}

		public bool IsXYParallel(Line otherLine)
		{
			bool result = false;
			YJKLine hyline = new YJKLine(otherLine.GetEndPoint(0), otherLine.GetEndPoint(1));
			XYZ xyz = new XYZ(this.startPoint.X, this.startPoint.Y, 0.0) - new XYZ(this.endPoint.X, this.endPoint.Y, 0.0);
			XYZ xyz2 = new XYZ(hyline.StartPoint.X, hyline.StartPoint.Y, 0.0) - new XYZ(hyline.EndPoint.X, hyline.EndPoint.Y, 0.0);
			double num = xyz.AngleTo(xyz2);
			if (Math.Abs(num - Math.PI) < 0.0001 || num < 0.0001)
			{
				result = true;
			}
			return result;
		}

		public double GetDistance(XYZ point)
		{
			return this.line.Distance(point);
		}

		public bool IsNearEndPoint(XYZ point)
		{
			bool result = false;
			if (point.DistanceTo(this.StartPoint) < 0.1)
			{
				result = true;
			}
			if (point.DistanceTo(this.EndPoint) < 0.1)
			{
				result = true;
			}
			return result;
		}

		public bool IsNearEndPoint(XYZ point, double l)
		{
			bool result = false;
			if (point.DistanceTo(this.StartPoint) < l)
			{
				result = true;
			}
			if (point.DistanceTo(this.EndPoint) < l)
			{
				result = true;
			}
			return result;
		}

		public double GetDistance(Line otherLine)
		{
			double result = -1.0;
			if (this.IsParallel(otherLine))
			{
				YJKLine hyline = new YJKLine(otherLine.GetEndPoint(0), otherLine.GetEndPoint(1));
				hyline.MakeUnBound();
				result = hyline.Line.Distance(this.startPoint);
			}
			return result;
		}

		public double GetXYDistance(Line otherLine)
		{
			double result = -1.0;
			if (this.IsXYParallel(otherLine))
			{
				YJKLine hyline = new YJKLine(otherLine.GetEndPoint(0), otherLine.GetEndPoint(1));
				XYZ xyz = new XYZ(hyline.StartPoint.X, hyline.StartPoint.Y, 0.0);
				XYZ xyz2 = new XYZ(hyline.EndPoint.X, hyline.EndPoint.Y, 0.0);
				XYZ xyz3 = new XYZ(this.startPoint.X, this.startPoint.Y, 0.0);
				if (xyz.IsAlmostEqualTo(xyz2))
				{
					xyz = new XYZ(hyline.StartPoint.X, 0.0, hyline.StartPoint.Z);
					xyz2 = new XYZ(hyline.EndPoint.X, 0.0, hyline.EndPoint.Z);
					xyz3 = new XYZ(this.startPoint.X, 0.0, this.startPoint.Z);
					if (Math.Abs(xyz.X - this.startPoint.X) < 0.0001)
					{
						xyz = new XYZ(0.0, hyline.StartPoint.Y, hyline.StartPoint.Z);
						xyz2 = new XYZ(0.0, hyline.EndPoint.Y, hyline.EndPoint.Z);
						xyz3 = new XYZ(0.0, this.startPoint.Y, this.startPoint.Z);
					}
				}
				Line line = YJKLineEx.YJKGetBound(xyz, xyz2);
				line.MakeUnbound();
				result = line.Distance(xyz3);
			}
			return result;
		}

		public double GetDPLineDistance(Line otherLine)
		{
			double result = -1.0;
			if (!this.IsParallel(otherLine))
			{
				XYZ hyendPoint = otherLine.GetEndPoint(0);
				XYZ hyendPoint2 = otherLine.GetEndPoint(1);
				XYZ dlineP = YJKRevitTools.GetDLineP(this.StartPoint, this.EndPoint, hyendPoint, hyendPoint2);
				XYZ dlineP2 = YJKRevitTools.GetDLineP(hyendPoint, hyendPoint2, this.StartPoint, this.EndPoint);
				result = dlineP.DistanceTo(dlineP2);
			}
			return result;
		}

		public XYZ GetXYVector(Line otherLine)
		{
			XYZ xyz = new XYZ(0.0, 0.0, 0.0);
			if (this.IsXYParallel(otherLine))
			{
				YJKLine hyline = new YJKLine(otherLine.GetEndPoint(0), otherLine.GetEndPoint(1));
				XYZ xyz2 = new XYZ(hyline.StartPoint.X, hyline.StartPoint.Y, 0.0);
				XYZ xyz3 = new XYZ(hyline.EndPoint.X, hyline.EndPoint.Y, 0.0);
				XYZ xyz4 = new XYZ(0.0, 0.0, 1.0);
				Line line;
				if (xyz2.IsAlmostEqualTo(xyz3))
				{
					xyz2 = new XYZ(hyline.StartPoint.X, 0.0, hyline.StartPoint.Z);
					xyz3 = new XYZ(hyline.EndPoint.X, 0.0, hyline.EndPoint.Z);
					line = YJKLineEx.YJKGetBound(new XYZ(this.startPoint.X, 0.0, this.startPoint.Z), new XYZ(this.endPoint.X, 0.0, this.endPoint.Z));
					xyz4 = new XYZ(0.0, 1.0, 0.0);
					if (Math.Abs(xyz2.X - this.startPoint.X) < 0.0001)
					{
						xyz2 = new XYZ(0.0, hyline.StartPoint.Y, hyline.StartPoint.Z);
						xyz3 = new XYZ(0.0, hyline.EndPoint.Y, hyline.EndPoint.Z);
						line = YJKLineEx.YJKGetBound(new XYZ(0.0, this.startPoint.Y, this.startPoint.Z), new XYZ(0.0, this.endPoint.Y, this.endPoint.Z));
						xyz4 = new XYZ(1.0, 0.0, 0.0);
					}
				}
				else
				{
					line = YJKLineEx.YJKGetBound(new XYZ(this.startPoint.X, this.startPoint.Y, 0.0), new XYZ(this.endPoint.X, this.endPoint.Y, 0.0));
				}
				line.MakeUnbound();
				XYZ xyz5 = (xyz2 - xyz3).CrossProduct(xyz4).Normalize() + xyz2;
				Line line2 = YJKLineEx.YJKGetBound(xyz2, xyz5);
				line2.MakeUnbound();
				IntersectionResultArray intersectionResultArray = new IntersectionResultArray();
				SetComparisonResult setComparisonResult = line.Intersect(line2, out intersectionResultArray);
				if (4 != (int)setComparisonResult && !intersectionResultArray.IsEmpty)
				{
					xyz = intersectionResultArray.get_Item(0).XYZPoint;
				}
				if (!xyz2.IsAlmostEqualTo(xyz))
				{
					xyz = (xyz - xyz2).Normalize();
				}
			}
			return xyz;
		}

		public XYZ GetVector(Line otherLine)
		{
			XYZ result = new XYZ(0.0, 0.0, 0.0);
			if (this.IsXYParallel(otherLine))
			{
				Line line = new YJKLine(otherLine.GetEndPoint(0), otherLine.GetEndPoint(1)).Line;
				line.MakeUnbound();
				IntersectionResult intersectionResult = new IntersectionResult();
				intersectionResult = line.Project(this.startPoint);
				XYZ xyz = new XYZ();
				if (intersectionResult != null)
				{
					xyz = intersectionResult.XYZPoint;
				}
				if (xyz != null)
				{
					result = (this.startPoint - xyz).Normalize();
				}
			}
			return result;
		}

		public XYZ IntersectionPoint(Line otherLine)
		{
			XYZ result = new XYZ();
			result = null;
			IntersectionResultArray intersectionResultArray = new IntersectionResultArray();
			SetComparisonResult setComparisonResult = this.line.Intersect(otherLine, out intersectionResultArray);
			if (4 != (int)setComparisonResult && intersectionResultArray != null && !intersectionResultArray.IsEmpty)
			{
				result = intersectionResultArray.get_Item(0).XYZPoint;
			}
			return result;
		}

		public XYZ IntersectionPoint(Line otherLine, bool unBound)
		{
			XYZ result = new XYZ();
			result = null;
			Line line = YJKLineEx.YJKGetBound(this.startPoint, this.endPoint);
			line.MakeUnbound();
			Line line2 = YJKLineEx.YJKGetBound(otherLine.GetEndPoint(0), otherLine.GetEndPoint(1));
			line2.MakeUnbound();
			IntersectionResultArray intersectionResultArray = new IntersectionResultArray();
			SetComparisonResult setComparisonResult = line.Intersect(line2, out intersectionResultArray);
			if (4 != (int)setComparisonResult && intersectionResultArray != null && !intersectionResultArray.IsEmpty)
			{
				result = intersectionResultArray.get_Item(0).XYZPoint;
			}
			return result;
		}

		public XYZ IntersectionPoint(Line otherLine, double dev)
		{
			XYZ xyz = new XYZ();
			xyz = null;
			Line line = YJKLineEx.YJKGetBound(this.startPoint, this.endPoint);
			XYZ hyendPoint = line.GetEndPoint(0);
			XYZ hyendPoint2 = line.GetEndPoint(1);
			XYZ hyendPoint3 = otherLine.GetEndPoint(0);
			XYZ hyendPoint4 = otherLine.GetEndPoint(1);
			line.MakeUnbound();
			Line line2 = YJKLineEx.YJKGetBound(otherLine.GetEndPoint(0), otherLine.GetEndPoint(1));
			line2.MakeUnbound();
			IntersectionResultArray intersectionResultArray = new IntersectionResultArray();
			SetComparisonResult setComparisonResult = line.Intersect(line2, out intersectionResultArray);
			if (4 != (int)setComparisonResult && intersectionResultArray != null && !intersectionResultArray.IsEmpty)
			{
				xyz = intersectionResultArray.get_Item(0).XYZPoint;
			}
			if (xyz == null)
			{
				XYZ dlineP = YJKRevitTools.GetDLineP(hyendPoint, hyendPoint2, hyendPoint3, hyendPoint4);
				if (YJKRevitTools.GetDLineP(hyendPoint3, hyendPoint4, hyendPoint, hyendPoint2).DistanceTo(dlineP) < dev)
				{
					xyz = dlineP;
				}
			}
			return xyz;
		}

		public XYZ IntersectionPoint(bool unBound, Line otherLine)
		{
			XYZ result = new XYZ();
			result = null;
			Curve curve = YJKLineEx.YJKGetBound(this.startPoint, this.endPoint);
			Line line = YJKLineEx.YJKGetBound(otherLine.GetEndPoint(0), otherLine.GetEndPoint(1));
			line.MakeUnbound();
			IntersectionResultArray intersectionResultArray = new IntersectionResultArray();
			SetComparisonResult setComparisonResult = curve.Intersect(line, out intersectionResultArray);
			if (4 != (int)setComparisonResult && intersectionResultArray != null && !intersectionResultArray.IsEmpty)
			{
				result = intersectionResultArray.get_Item(0).XYZPoint;
			}
			return result;
		}

		public XYZ GetNearlyPoint(XYZ basePoint)
		{
			double num = this.startPoint.DistanceTo(basePoint);
			double num2 = this.endPoint.DistanceTo(basePoint);
			if (num <= num2)
			{
				return this.startPoint;
			}
			return this.endPoint;
		}

		public bool IsVertical(Line line)
		{
			if (line == null)
			{
				return false;
			}
			XYZ xyz = this.StartPoint.Subtract(this.EndPoint).Normalize();
			XYZ xyz2 = line.GetEndPoint(0).Subtract(line.GetEndPoint(1)).Normalize();
			double num = xyz.AngleTo(xyz2);
			return Math.Abs(num - Math.PI*.5) < 0.009 || Math.Abs(num - 4.71238898038469) < 0.009;
		}

		public bool IsPointOnLine(XYZ xyz)
		{
			bool result = false;
			if (Math.Abs(xyz.DistanceTo(this.startPoint) + xyz.DistanceTo(this.endPoint) - this.startPoint.DistanceTo(this.endPoint)) < 0.0001)
			{
				result = true;
			}
			return result;
		}

		public bool IsPointOnLineExtension(XYZ xyz)
		{
			bool result = false;
			if (Math.Abs(Math.Abs(xyz.DistanceTo(this.startPoint) - xyz.DistanceTo(this.endPoint)) - this.startPoint.DistanceTo(this.endPoint)) < 0.0001)
			{
				result = true;
			}
			return result;
		}

		public bool IsPointOnCurveLine(XYZ xyz)
		{
			bool result = false;
			if (this.IsPointOnLine(xyz) || this.IsPointOnLineExtension(xyz))
			{
				result = true;
			}
			return result;
		}

		public bool IsLineOnLine(Line otherLine)
		{
			bool result = false;
			if (this.IsPointOnCurveLine(otherLine.GetEndPoint(0)) && this.IsPointOnCurveLine(otherLine.GetEndPoint(1)))
			{
				result = true;
			}
			return result;
		}

		public XYZ GetProject(XYZ point)
		{
			IntersectionResult intersectionResult = new IntersectionResult();
			intersectionResult = this.line.Project(point);
			XYZ result = null;
			if (intersectionResult != null)
			{
				result = intersectionResult.XYZPoint;
			}
			return result;
		}

		public XYZ GetVertial(XYZ point)
		{
			XYZ xyz = this.startPoint;
			XYZ xyz2 = this.endPoint;
			if (xyz.Z > xyz2.Z)
			{
				XYZ xyz3 = xyz;
				xyz = xyz2;
				xyz2 = xyz3;
			}
			double num = xyz2.Z - xyz.Z;
			double num2 = new XYZ(xyz.X, xyz.Y, 0.0).DistanceTo(new XYZ(xyz2.X, xyz2.Y, 0.0));
			double num3 = new XYZ(xyz.X, xyz.Y, 0.0).DistanceTo(new XYZ(point.X, point.Y, 0.0));
			double num4 = num * num3 / num2;
			return new XYZ(point.X, point.Y, xyz.Z + num4);
		}

		public List<XYZ> GetLayLineXYZList(XYZ globalPoint, int count, double radio, double offSet)
		{
			List<XYZ> list = new List<XYZ>();
			if (globalPoint == null || count < 1 || radio < -0.0001)
			{
				throw new Exception("布置参数有错误");
			}
			XYZ xyz;
			XYZ xyz2;
			if (this.startPoint.DistanceTo(globalPoint) > this.endPoint.DistanceTo(globalPoint))
			{
				xyz = new XYZ(this.endPoint.X, this.endPoint.Y, offSet);
				xyz2 = new XYZ(this.startPoint.X, this.startPoint.Y, offSet);
			}
			else
			{
				xyz = new XYZ(this.startPoint.X, this.startPoint.Y, offSet);
				xyz2 = new XYZ(this.endPoint.X, this.endPoint.Y, offSet);
			}
			if (count == 1 && radio < 0.0001)
			{
				list.Add(xyz);
			}
			else
			{
				XYZ xyz3 = (xyz2 - xyz).Normalize();
				double num = xyz2.DistanceTo(xyz) / ((double)(count - 1) + 2.0 * radio);
				double num2 = num * radio;
				for (int i = 0; i < count; i++)
				{
					list.Add(xyz + (num2 + num * (double)i) * xyz3);
				}
			}
			return list;
		}

		public List<XYZ> GetLayLineXYZList(XYZ globalPoint, double distance, double sideDistance, double offSet)
		{
			List<XYZ> list = new List<XYZ>();
			if (globalPoint == null || distance < -0.0001 || sideDistance < -0.0001)
			{
				throw new Exception("布置参数有错误");
			}
			XYZ xyz;
			XYZ xyz2;
			if (this.startPoint.DistanceTo(globalPoint) > this.endPoint.DistanceTo(globalPoint))
			{
				xyz = new XYZ(this.endPoint.X, this.endPoint.Y, offSet);
				xyz2 = new XYZ(this.startPoint.X, this.startPoint.Y, offSet);
			}
			else
			{
				xyz = new XYZ(this.startPoint.X, this.startPoint.Y, offSet);
				xyz2 = new XYZ(this.endPoint.X, this.endPoint.Y, offSet);
			}
			XYZ xyz3 = (xyz2 - xyz).Normalize();
			double num = xyz2.DistanceTo(xyz);
			if (num > sideDistance)
			{
				int num2 = Convert.ToInt32(Math.Floor((num - sideDistance) / distance + 1.0));
				for (int i = 0; i < num2; i++)
				{
					list.Add(xyz + (sideDistance + distance * (double)i) * xyz3);
				}
				return list;
			}
			throw new Exception("选择的线段过短，无法满足设置的参数");
		}

		public List<XYZ> GetLineXYZList(XYZ globalPoint, double distance)
		{
			List<XYZ> list = new List<XYZ>();
			XYZ item = (this.line.GetEndPoint(0) - this.line.GetEndPoint(1)).Normalize() * distance + globalPoint;
			XYZ item2 = -(this.line.GetEndPoint(0) - this.line.GetEndPoint(1)).Normalize() * distance + globalPoint;
			list.Add(item);
			list.Add(item2);
			return list;
		}

		public double lookForK(XYZ start, XYZ end)
		{
			double x = start.X;
			double x2 = end.X;
			double y = start.Y;
			return (end.Y - y) / (x2 - x);
		}

		private Line line;

		private bool isBound = true;

		private XYZ startPoint = new XYZ(0.0, 0.0, 0.0);

		private XYZ endPoint = new XYZ(0.0, 0.0, 0.0);
	}
}
